<?php



namespace App\Http\Middleware;



use Closure;

use Illuminate\Support\Facades\DB;

use Illuminate\Support\Facades\Session;

use think\response\Redirect;



class CheckLogin

{

    /**

     * Handle an incoming request.

     * @param  \Illuminate\Http\Request  $request

     * @param  \Closure  $next

     * @return mixed

     */

    public function handle($request, Closure $next)

    {

        //$response = $next($request);
//        $goodinfo = DB::table("goodslist")->where("id", $request->id)->first();
//
//        if (!Session::get("userid")) {
//
//            //如果用户未登录，就强制跳转到用户登陆界面
//
//            return redirect()->route('view_login');
//
//        }

        //        else if(!$goodinfo){

        //            //如果商品id不存在就跳转到404页面

        //            return response()->view('error.404');

        //        }

        return $next($request);

    }

}

